home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / NRPAS13 / INDEXX.DEM < prev    next >
Text File  |  1991-04-29  |  899b  |  43 lines

  1. PROGRAM d8r5(input,output,dfile);
  2. (* driver for routine INDEXX *)
  3. CONST
  4.    np=100;
  5. TYPE
  6.    glsarray = ARRAY [1..np] OF real;
  7.    gliarray = ARRAY [1..np] OF integer;
  8. VAR
  9.    i,j : integer;
  10.    a : glsarray;
  11.    indx : gliarray;
  12.    dfile : text;
  13.  
  14. (*$I MODFILE.PAS *)
  15. (*$I INDEXX.PAS *)
  16.  
  17. BEGIN
  18.    glopen(dfile,'tarray.dat');
  19.    readln(dfile);
  20.    FOR i := 1 to 100 DO BEGIN
  21.       read(dfile,a[i])
  22.    END;
  23.    close(dfile);
  24. (* generate index for sorted array *)
  25.    indexx(np,a,indx);
  26. (* writeln original array *)
  27.    writeln('original array:');
  28.    FOR i := 1 to 10 DO BEGIN
  29.       FOR j := 1 to 10 DO BEGIN
  30.          write(a[10*(i-1)+j]:6:2)
  31.       END;
  32.       writeln
  33.    END;
  34. (* writeln sorted array *)
  35.    writeln('sorted array:');
  36.    FOR i := 1 to 10 DO BEGIN
  37.       FOR j := 1 to 10 DO BEGIN
  38.          write(a[indx[10*(i-1)+j]]:6:2)
  39.       END;
  40.       writeln
  41.    END
  42. END.
  43.